package com.mazaiting.classfile.constant.info;

import com.mazaiting.classfile.ClassReader;
import com.mazaiting.classfile.constant.ConstantPool;
import com.mazaiting.util.ByteUtil;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 * 8字节存 储IEEE754双精度浮点数
 * @author mazaiting
 * @since 2021/8/12
 */
@Slf4j
@Getter
public class ConstantDoubleInfo extends ConstantInfo{

    /**
     * Double 型数据
     */
    private double value;

    public ConstantDoubleInfo(ConstantPool pool, short tag) {
        super(pool, tag);
    }

    @Override
    public void readInfo(ClassReader reader) {
        this.value = ByteUtil.byteToDouble(reader.readU8());
    }

    @Override
    public String toString() {
        return "ConstantDoubleInfo{" +
                "value=" + value +
                '}';
    }
}
